package com.wn.config;

import com.wn.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//配置拦截器
@Configuration
public class TokenInterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /**
         * 注册拦截器：告诉springboot那个类是拦截器
         */
        registry.addInterceptor(new TokenInterceptor())
                .addPathPatterns("/**")//拦截所有请求
                .excludePathPatterns(
                        "/login",
                        "/**/*.js",
                        "/**/*.css",
                        "/**/*.ico",
                        "/**/*.html",
                        "/**/*.jpg",
                        "/**/*.png",
                        "/error",
                        "/**/*.min.map",
                        "/swagger-resources", //放行swagger
                        "/v3/api-docs",
                        "/v2/api-docs",
                        "/js/**",
                        "/css/**",
                        "/images/**",
                        "/img/**",
                        "/plugins/**"
                );
    }
}